package TFIDF;

import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapreduce.lib.db.DBWritable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class receiveData implements DBWritable, Writable {
    private String FilmName;
    private String common;

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(FilmName);
        dataOutput.writeUTF(common);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        FilmName = dataInput.readUTF();
        common = dataInput.readUTF();
    }

    @Override
    public void write(PreparedStatement statement) throws SQLException {
        statement.setString(2, FilmName);
        statement.setString(6, common);
    }

    @Override
    public void readFields(ResultSet resultSet) throws SQLException {
        FilmName = resultSet.getString(2);
        common = resultSet.getString(6);
    }

    @Override
    public String toString() {
        return FilmName + "\t" + common;
    }

    public void set(String filmName, String common) {
        FilmName = filmName;
        this.common = common;
    }

    public String getFilmName() {
        return FilmName;
    }

    public void setFilmName(String filmName) {
        FilmName = filmName;
    }

    public String getCommon() {
        return common;
    }

    public void setCommon(String common) {
        this.common = common;
    }
}
